using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Mbs.ComponentModel.Container.Metadata;
using Mbs.Reflection;

namespace Mbs.ComponentModel.Container.Context
{
    [Serializable]
    public class InjectContext : IInjectContext
    {
        public IMicroKernel Kernel { get; private set; }
        public IComponentInfo Component { get; private set; }
        public object Instance { get; internal set; }
        public KeyValuePair<MemberInfo, string>[] Members { get; private set; }


        public InjectContext(IMicroKernel kernel, IComponentInfo info, object instance, KeyValuePair<MemberInfo, string>[] members)
        {
            Kernel = kernel;
            Component = info;
            Instance = instance;
            Members = members;
        }
    }


    [Serializable]
    public class InjectContext<TMemeber> : IInjectContext<TMemeber> where TMemeber : MemberInfo
    {
        public IMicroKernel Kernel { get; private set; }
        public IComponentInfo Component { get; private set; }
        public object Instance { get; internal set; }
        public KeyValuePair<TMemeber, string>[] Members { get; private set; }

        KeyValuePair<MemberInfo, string>[] IInjectContext.Members
        {
            get { return (from m in Members select new KeyValuePair<MemberInfo, string>(m.Key, m.Value)).ToArray(); }
        }

        public InjectContext(IMicroKernel kernel, IComponentInfo info, object instance, KeyValuePair<TMemeber, string>[] members)
        {
            Kernel = kernel;
            Component = info;
            Instance = instance;
            Members = members;
        }

       
    }
}
